<template>
  <div class='plan-project'>
    <base-table ref="table" :tableModel="projectList" :tableItemConfig="tableConfig" hasIndex isSelect @selectionChange="selectionChange">
    </base-table>
    <pagination v-if="total>0" :total="total" :page.sync="serachMap.pageNum" :limit.sync="serachMap.pageSize" @change="getList" />
  </div>
</template>

<script>
import { listOsiProject } from '../api/project'
export default {
  data () {
    return {
      dialogVisible: false,
      // 搜索条件
      serachMap: {
        pageNum: 1,
        pageSize: 5,
      },
      formData: {},
      // 表格配置
      // 选择题表格配置
      tableConfig: [
        {
          label: '任务编号',
          prop: 'taskNum',
        },
        {
          label: '任务名称',
          prop: 'taskName',
        },
        {
          label: '任务线路',
          prop: 'taskLine',
        },
        {
          label: '任务内容',
          prop: 'taskContent',
        }
      ],
      // 巡检项目列表数据
      projectList: [],
      // 总条数
      total: '',
      // 表格加载
      loading: false,
      planProjectList: [],
    };
  },
  computed: {},
  watch: {},
  created () {
    this.getList()
  },
  mounted () {

  },
  methods: {
    show () {
      this.$nextTick(() => {
        this.$refs.table.clearSelection()
      })
    },
    // 数组转字符串
    combineString (arr) {
      const answerItem = arr.map(item => `${item.itemName}: ${item.itemValue}`)
      const result = answerItem.join(' ')
      return result
    },
    async getList () {
      const response = await listOsiProject(this.serachMap)
      if (response.code === 200) {
        this.projectList = response.rows
        this.total = response.total
      }
    },
    handleSerach () {
      this.serachMap = {
        pageNum: 1,
        pageSize: 5,
        keyword: undefined
      }
      this.getList()
    },
    // 表格点击数据发生改变
    selectionChange (val) {
      this.$emit('selectChange', val)
    },
  },

  components: {
  },
}
</script>

<style lang='less' scoped>
</style>